#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<int>> ret;
    bool bcur[7];
    vector<int> cur;
    vector<vector<int>> permute(vector<int>& nums) {
        _permute(nums);
        return ret;
    }
    void _permute(vector<int>& nums)
    {
        if (nums.size() == cur.size())
        {
            ret.push_back(cur);
            return;
        }

        for (int i = 0; i < nums.size(); i++)
        {
            if (!bcur[i])
            {
                cur.push_back(nums[i]);
                bcur[i] = true;
                _permute(nums);
                cur.pop_back();
                bcur[i] = false;
            }
        }
    }
};